import echarts from "echarts/lib/echarts";
const labelRight = {
  position: "right",
  color: "red",
};
const labelLeft = {
  position: "left",
  color: "green",
};
export const trafficOptions = ({ type }) => ({
  tooltip: {
    trigger: "axis",
    axisPointer: {
      type: "shadow",
    },
  },
  grid: {
    top: 0,
    bottom: 0,
    left: '8%',
    right: 0,
  },
  xAxis: {
    type: "value",
    position: "top",
    splitLine: {
      show: false,
    },
  },
  yAxis: {
    type: "category",
    inverse: true,
    axisLine: { show: false },
    axisLabel: { show: false },
    axisTick: { show: false },
    splitLine: { show: false },
    data:
      type === "month"
        ? [
            "一月",
            "二月",
            "三月",
            "四月",
            "五月",
            "六月",
            "七月",
            "八月",
            "九月",
            "十月",
            "十一月",
          ]
        : ["第一季度", "第二季度", "第三季度", "第四季度"],
  },
  series: [
    {
      name: "同比",
      type: "bar",
      color: "#36cfc9",
      label: {
        show: true,
        formatter: "{b} {c}%",
      },
      data:
        type === "month"
          ? [
              { value: 70, label: labelLeft },
              { value: 19, label: labelLeft },
              { value: -53, label: labelRight },
              { value: 1128, label: labelLeft },
              { value: -73, label: labelRight },
              { value: 320, label: labelLeft },
              { value: 236316, label: labelLeft },
              { value: 87, label: labelLeft },
              { value: 188, label: labelLeft },
              { value: 20, label: labelLeft },
              { value: 40, label: labelLeft },
            ]
          : [{ value: 103 }, { value: 40 }, { value: 73 }, { value: 40 }],
    },
  ],
});

export const userOptions = (params = {}) => ({
  header: params.header,
  data: params.data,
});
